package cn.bookcycle.panda.pay.constant;

import java.util.HashMap;
import java.util.Map;

import cn.bookcycle.panda.pay.util.WechatUtil;

/**
 * 常量数据
 * 
 * @author liufenglin
 * @date 2018年1月29日
 */
public class BusinessData {

	/**
	 * 把请求参数的参数名映射为微信接口规定的参数名
	 * 这些参数是微信接口必须的参数
	 * 微信接口非必须的参数则不做映射
	 * 微服务参数名----->微信请求参数名
	 */
	public static final Map<String, String> NECESSARY_PARAMETERS_MAP = new HashMap<String, String>();
	static {
		NECESSARY_PARAMETERS_MAP.put("appId", "appid");
		NECESSARY_PARAMETERS_MAP.put("mchId", "mch_id");
		NECESSARY_PARAMETERS_MAP.put("nonceStr", "nonce_str");
		NECESSARY_PARAMETERS_MAP.put("sign", "sign");
		NECESSARY_PARAMETERS_MAP.put("body", "body");
		NECESSARY_PARAMETERS_MAP.put("tradeNo", "out_trade_no");
		NECESSARY_PARAMETERS_MAP.put("totalFee", "total_fee");
		NECESSARY_PARAMETERS_MAP.put("spbillCreateIp", "spbill_create_ip");
		NECESSARY_PARAMETERS_MAP.put("tradeType", "trade_type");
		NECESSARY_PARAMETERS_MAP.put("notifyUrl", "notify_url");
	}
	
	/** 存放account和对应开发者appId的map */
	public static final Map<String, String> APP_ID_MAP = new HashMap<String, String>();
	/** 存放account和对应商户mchId的map */
	public static final Map<String, String> MCH_ID_MAP = new HashMap<String, String>();
	/** 存放account和对应商户key */
	public static final Map<String, String> KEY_MAP = new HashMap<String, String>();
	/** 存放account和对应的默认回调地址 */
	public static final Map<String, String> DEFAULT_NOTIFY_URL_MAP = new HashMap<String, String>();
	/** 存放mchId与对应account的map */
	public static final Map<String, String> MCH_ID_ACCOUNT_MAP = new HashMap<String, String>();;
	
	static {
		APP_ID_MAP.put("wechatpay00001", WeChatData.APP_ID_WSN_00001);
		MCH_ID_MAP.put("wechatpay00001", WeChatData.MCH_ID_WSN_00001);
		KEY_MAP.put("wechatpay00001", WeChatData.KEY_WSN_00001);
		DEFAULT_NOTIFY_URL_MAP.put("wechatpay00001", WeChatData.DEFAULT_NOTIFY_URL_WSN_00001);
		MCH_ID_ACCOUNT_MAP.put(WeChatData.MCH_ID_WSN_00001, "wechatpay00001");
	}
	
	/**请求成功状态码*/
	public static final String SUCCESS_CODE = "50001";
	
	/**请求失败状态码*/
	public static final String FAILURE_CODE = "50005";
	
	/**用户已经支付状态码*/
	public static String PAIED_CODE = "50007";
	
	/**用户尚未支付状态码*/
	public static String UN_PAY_CODE = "50009";
	
	/**支付请求默认返回的json串，失败状态码*/ // 
	public static final String DEFAULT_STATUS = "{\"status\":" + "\"" + FAILURE_CODE + "\"}";
	
	/**微信接口请求的必须参数拼接成的字符串*/
	public static final String NECESSARY_PARAMETERS_STR = "body&tradeNo&totalFee&spbillCreateIp&account&notifyUrl";
	
	/** 通知微服务调用者的地址 */
	public static final String NOTIFY_CALLER_URL = "http://localhost:9090/notify"; 
	
	/** 数据库微服务调用地址 */
	public static final String DB_URI = "http://119.29.242.75:3002/db";
	 
	/** 已经支付的标识符 */
	public static final String PAID = "status=paid";
	
	/** 规定时间内未支付的标识符 */
	public static final String UNPAID = "status=unpaid";
	
	/** 设置向微信支付接口发起的总询问次数 */
	public static int total = 30;
	
}
